home *** CD-ROM | disk | FTP | other *** search
/ MacFormat España 19 / macformat_19.iso / Shareware / Developers / N Game Library1.1.0E(68k) / Audio Sample / Audio_Sample.c < prev   
Encoding:
C/C++ Source or Header  |  1996-06-23  |  1.7 KB  |  80 lines  |  [TEXT/CWIE]

  1. /*============================================================
  2.  
  3.                   N-Music/Sound Sample program
  4.                     
  5. ============================================================*/
  6.  
  7. #include            "N_Library.h"
  8.  
  9. void             DoEvent            (EventRecord *eventPtr);
  10. void             DoError            (Str255 errorString);
  11. WindowPtr     CreateWindow         (Str255 name);
  12.  
  13.  
  14. #define        WindowSizeX        320
  15. #define        WindowSizeY        240
  16.  
  17. short        NewWindowX;
  18. short        NewWindowY;
  19.  
  20. short        Data_Rsrc = 0;
  21.  
  22.  
  23. short        Sounds[] = { 1000,1001,0 };                    //'SND'resource id
  24. short        Music1[] = { 1000,1001,-1 };                    //music 1 block (1000,1001,1001,1001,,,,)
  25.  
  26. void main(void)
  27. {
  28.     WindowPtr    window;
  29.  
  30.  
  31.     ToolboxInit();
  32.     ColorCheck();
  33.     window = CreateWindow("\pN Game Library <Audio Sample>");
  34.  
  35.     Open_Resource_File(128,1,&Data_Rsrc);
  36.     N_Pict_Draw(128,0,0,(GrafPtr)window,true);
  37.     N_Sound_Load(&Sounds[0]);                                //open sound channels and read 'SND'
  38.     N_Music_Set(1,&Music1[0]);                                //set up music1 blocks
  39.     N_Music_Play(1);                                        //play music1
  40.  
  41.     do
  42.     {
  43.         N_Music_Loop();
  44.     }
  45.     while (!Button());
  46.  
  47.     N_Music_Out(180);                                        //Fade out
  48.     do
  49.     {
  50.         N_Music_Loop();
  51.     }
  52.     while (FO_Flag == true);
  53.  
  54.     ColorRevert();
  55.     N_Sound_Close();                                        //close sounds channels
  56.  
  57. }
  58.  
  59.  
  60. WindowPtr CreateWindow (Str255 name)
  61. {
  62.     WindowPtr    window;
  63.     short        centerX,centerY;
  64.     short        windowWidth,windowHeight;
  65.  
  66.  
  67.     window = GetNewWindow (128,nil,(WindowPtr)-1L );
  68.     centerX  = (qd.screenBits.bounds.right -qd.screenBits.bounds.left)/2;
  69.     centerY  = (qd.screenBits.bounds.bottom -qd.screenBits.bounds.top)/2;
  70.     SetWTitle(window,name);
  71.     MoveWindow(window,NewWindowX=centerX-(WindowSizeX/2),NewWindowY=centerY-(WindowSizeY/2),false);
  72.     SizeWindow(window,WindowSizeX,WindowSizeY,TRUE);
  73.  
  74.     ShowWindow(window);
  75.     SetPort((GrafPtr)window );
  76.     return (WindowPtr)window;
  77. }
  78.     
  79.  
  80.